<template>
	<div v-if="navType == 'scjd'" class="screen-nav sc-nav">
		<div class="screen-nav-title">坞城市场监督管理平台</div>
	</div>
	<!-- 顶部tab栏 -->
	<div v-else class="screen-nav">
		<h1>
			<p @click="defaultLink" class="title">{{ title }}</p>
			<!-- <router-link :to="defaultLink()" class="title">{{ title }}</router-link> -->
		</h1>
		<ul class="nav">
			<li v-for="(route, index) in routes" :key="index">
				<!-- <router-link :to="routesLink(route.link)">{{ route.title }}</router-link> -->
				<p @click="routesLink(route.link)" :class="[activeRoute == route.link ? 'router-link-active' : '']">{{
					route.title }}</p>
			</li>
		</ul>

		<ul class="tiqnqi">
			<li>
				<span>天气：</span>
				<span>{{ tianqiData.weather }}</span>
			</li>
			<li>
				<span>温度：</span>
				<span>{{ tianqiData.temperature }}℃</span>
			</li>
			<li>
				<span>湿度：</span>
				<span>{{ tianqiData.humidity }}</span>
			</li>
			<li>
				<span>风力：</span>
				<span>{{ tianqiData.windPower }}</span>
			</li>
		</ul>
	</div>
</template>
<script>
import { HomeDb } from '@/api'

export default {
	name: 'ScreenNav',
	props: {
		navType: {
			type: String,
			required: false,
		},
	},
	created() {
		if (this.$route.path.includes('/by')) {
			this.title = '北营街道综合行政执法智慧服务平台'
			this.prefixRoute = '/by'
		} else if (this.$route.path.includes('/cg')) {
			this.title = '小店区城管指挥中心'
			this.prefixRoute = '/cg'
		} else {
			this.title = '综合执法一张图'
			this.prefixRoute = ''
		}
	},
	data() {
		return {
			routes: [{
				"display": 0,
				"id": 1,
				"link": "/jklb",
				"linkType": 1,
				"openType": "1",
				"rank": 2,
				"title": "云巡查"
			},
			{
				"display": 0,
				"id": 3,
				"link": "/default",
				"linkType": 1,
				"openType": "1",
				"rank": 3,
				"title": "行政执法一张图"
			}],
			title: '',
			prefixRoute: '',
			activeRoute: '',
			tianqiData: {}
		}
	},
	computed: {
		// defaultLink() {
		// 	return () => {
		// 		if (this.prefixRoute) {
		// 			return this.prefixRoute + '/default'
		// 		} else {
		// 			return '/default'
		// 		}
		// 	}
		// },
		// routesLink() {
		// 	return (link) => {
		// 		if (this.prefixRoute) {
		// 			return this.prefixRoute + link
		// 		} else {
		// 			return link
		// 		}
		// 	}
		// }
	},
	mounted() {
		this.tianqiFn()
	},
	methods: {
		tianqiFn() {
			AMap.plugin('AMap.Weather', () => {
				var weather = new AMap.Weather();
				//查询实时天气信息, 查询的城市到行政级别的城市，如朝阳区、杭州市
				weather.getLive('长子县', (err, data) => {
					console.log(data, '长子县')
					this.tianqiData = data
				});
			});
		},

		routesLink(link) {
			this.activeRoute = link
			if (this.prefixRoute) {
				this.$router.push(this.prefixRoute + link)
			} else {
				this.$router.push(link)
			}
		},
		defaultLink() {
			this.activeRoute = '';
			if (this.prefixRoute) {
				this.$router.push(this.prefixRoute + '/default')
			} else {
				this.$router.push('/default')
			}
		},
		getRoutes() {
			HomeDb.getOaMenuConfig().then(res => {

				if (res.code == 200) {
					let data = res.data;
					this.routes = data.filter(item => item.link != 'default')
				}
			})
		}
	},
}
</script>

<style lang="less" scoped>
.screen-nav {
	background: url(../../assets/images/layout/top-one.png) no-repeat 0 0;
	width: 100%;
	height: 85px;
	position: absolute;
	width: 100%;
	left: 0;
	top: 0;
	z-index: 1987;
	display: flex;
	align-items: center;

	h1 {
		width: 34%;
	}
}

.sc-nav {
	background: url(../../assets/images/layout/sc-top.png) no-repeat;
	background-position: center center;

	.screen-nav-title {
		width: 100%;
		font-size: 40px;
		margin-top: -10px;
		font-family: Source Han Sans SC;
		font-weight: bold;
		color: #EFF6FF;
		background: linear-gradient(1deg, #D4E7EE 0%, #F9FEFF 99.0478515625%);
		-webkit-background-clip: text;
		-webkit-text-fill-color: transparent;
		text-align: center;
	}
}

.title {
	margin: 0 20px;
	font-size: 32px;
	background-image: -webkit-linear-gradient(top, #20A8FF, #26FFED);
	background-clip: text;
	-webkit-background-clip: text;
	-webkit-text-fill-color: transparent;
	cursor: pointer;
}

.nav {
	display: flex;
	// margin-left: 264px;
	margin-left: 80px;

	li {
		margin: 0 20px;
	}

	p {
		color: #fff;
		font-size: 22px;
		position: relative;
		cursor: pointer;

		&:after {
			content: '';
			display: block;
			width: 0;
			height: 4px;
			// background: #00DCFF;
			border-radius: 2px;
			position: absolute;
			bottom: -10px;
			left: 50%;
			margin-left: -18px;
			transition: all .5s ease;
		}
	}

	.router-link-active {
		color: #00DCFF;
		font-weight: bold;

		&::after {
			width: 36px;
			content: '';
			display: block;
			// width: 0;
			height: 4px;
			background: #00DCFF;
			border-radius: 2px;
			position: absolute;
			bottom: -10px;
			left: 50%;
			margin-left: -18px;
			transition: all .5s ease;
		}
	}

	// a {
	// 	color: #fff;
	// 	font-size: 22px;
	// 	position: relative;

	// 	&:after {
	// 		content: '';
	// 		display: block;
	// 		width: 0;
	// 		height: 4px;
	// 		background: #00DCFF;
	// 		border-radius: 2px;
	// 		position: absolute;
	// 		bottom: -10px;
	// 		left: 50%;
	// 		margin-left: -18px;
	// 		transition: all .5s ease;
	// 	}
	// }

	// .router-link-active {
	// 	color: #00DCFF;
	// 	font-weight: bold;

	// 	&::after {
	// 		width: 36px;
	// 	}
	// }
}

.tiqnqi {
	display: flex;
	position: fixed;
	right: 20px;
	li {
		display: flex;
		margin-right: 16px;

		span {
			display: block;
			color: #fff;
		}
	}
}
</style>